package lion.framework.core.patch.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.framework.core.bean.BeanFactory;
import lion.framework.core.patch.IPatch;
import lion.framework.core.patch.PatchManager;

@AnnoProcessor(Patch.class)
public class PatchAnnoProcessor implements IAnnotationProcessor {

	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_CLASS);
		if (!IPatch.class.isAssignableFrom(clazz)) { return; }

		Patch update = (Patch) anno;

		PatchManager.addUdpater(update.value(), (IPatch) BeanFactory.create(clazz));
	}

}
